/**
 * 
 * @class NG.response.GetCategories
 * @extends Ext.util.Observable
 */
NG.response.GetCategories = Ext.extend(NG.response.Response, {

	/**
	 * array of Category objects
	 */
	categories: [],
	

	constructor: function(config){
		NG.response.GetCategories.superclass.constructor.call(this, config);
	},
	
	/**
	 * Parses given xmlData (response data) <br>
	 * Fulfills {NG.response.GetCategories} members according to parsed xml data
	 * 
	 * @param {String} xmlData - response data
	 * Called by {@link NG.response.Response.constructor}
	 */
	init: function (xmlData) {
		NG.response.GetCategories.superclass.init.call(this, xmlData);
		this.categories = [];
		var xmlStr = fleegix.xml.parse(fleegix.xml.createDoc(xmlData), 'string').string;
		var id = 0;
		var catArray = fleegix.xml.parse(fleegix.xml.createDoc(xmlStr), "Category").Category;
		for (var i = 0 ; i<catArray.length; i++) {
			var category = catArray[i];
			if (!Ext.isDefined(category.CatSubCategories)) continue; //it means sub category node
			var cp = category.CatParams;

			this.categories.push({
		        id: id++,
		        refKeyword: cp.RefKeyword,
		        refName: cp.RefName,
		        catName: cp.CatName,
		        catActive: cp.CatActive,
		        catVisible: cp.CatVisible,
		        catID: cp.CatID,
		        iconType: cp.CatIconType,
		        startScale: cp.StartScale,
		        endScale: cp.EndScale
			});					
		}
		
		/*
		var doc = fleegix.xml.createDoc(xmlStr);
		var refKeyword = fleegix.xml.parse(doc, "RefKeyword").RefKeyword;
		var refName = fleegix.xml.parse(doc, "RefName").RefName;
		var catName = fleegix.xml.parse(doc, "RefName").RefName;
		var catGroupName = fleegix.xml.parse(doc, "CatGroupName").CatGroupName;
		var catActive = parseInt(fleegix.xml.parse(doc, "CatActive").CatActive);
		var catVisible = parseInt(fleegix.xml.parse(doc, "CatVisible").CatVisible);
		var catID = fleegix.xml.parse(doc, "CatID").CatID;
		var catIconType = fleegix.xml.parse(doc, "CatIconType").CatIconType;
		var readOnly = fleegix.xml.parse(doc, "ReadOnly").ReadOnly;
		var startScale = parseFloat(fleegix.xml.parse(doc, "StartScale").StartScale);
		var endScale = parseFloat(fleegix.xml.parse(doc, "EndScale").EndScale);
		
		this.categories.push({
	        id: id++,
	        refKeyword: refKeyword,
	        refName: refName,
	        catName: catName,
	        catActive: catActive,
	        catVisible: catVisible,
	        catID: catID,
	        iconType: catIconType,
	        startScale: startScale,
	        endScale: endScale
		});
		*/
	},

	/**
	 * 
	 * @returns {Array} array of Category objects
	 */
	getCategories: function () {
		return this.categories;
	}
	
});